package com.sugon.controller.report;


import com.sugon.entity.DevMaintenWorkEntity;
import com.sugon.service.DevMaintenWorkService;
import com.sugon.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 工单执行情况追踪
 */
@Controller
@RequestMapping("devPlanReport")
public class DevPlanReportController {

    @Autowired
    private DevMaintenWorkService devMaintenWorkService;

    /**
     * 紧急维修工单实施情况跟踪报表(当天的数据)
     */
    @RequestMapping("/getDevPlanImplementation ")
    @ResponseBody
    public R getDevPlanImplementation(@RequestParam Map<String, Object> params) {

        Map<String, Object> resultMap = new HashMap();
        List<DevMaintenWorkEntity> list = devMaintenWorkService.getDevPlanImplementation(params);
        /**
         * 数量 --num
         */
        List numlist = new ArrayList();
        /**
         * 状态名称  3待确认  2待分派   1维修中 0完成
         */
        List namelist = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            numlist.add(list.get(i).getDevStatus());
            namelist.add(list.get(i).getNum());
        }
        resultMap.put("numlist", numlist);
        resultMap.put("namelist", namelist);

        return R.ok().put("list", resultMap);
    }

}
